package top.iflyoung.cim.biz.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.iflyoung.cim.biz.entity.ChatRouteInfo;
import top.iflyoung.cim.biz.mapper.ChatRouteInfoMapper;
import top.iflyoung.cim.biz.service.ChatRouteInfoService;
import top.iflyoung.cim.common.util.VerifyUtil;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * @author liguiyang
 * @description
 * @sine 1.8
 * @date 2021/9/418:34
 **/
@Service("chatRouteInfoService")
public class ChatRouteInfoServiceImpl extends ServiceImpl<ChatRouteInfoMapper, ChatRouteInfo> implements ChatRouteInfoService {
    @Override
    public long removeByUserId(@NotNull Long userId) {
        if (VerifyUtil.isEmpty(userId)) {
            throw new NullPointerException("传入的用户ID为空");
        }
        return baseMapper.deleteByUserId(userId);
    }

    @Override
    public List<ChatRouteInfo> findByUserId(Long userId) {
        List<ChatRouteInfo> result = new ArrayList<>();
        if (!VerifyUtil.isEmpty(userId)) {
            result.addAll(baseMapper.queryByUserId(userId));
        }
        return result;
    }
}
